package com.woniu.smallmedical.controller;

import com.woniu.smallmedical.entity.AdjustmentMedicine;
import com.woniu.smallmedical.entity.PageBean;
import com.woniu.smallmedical.entity.ResponseResult;
import com.woniu.smallmedical.mapper.AdjustmentMedicineMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@CrossOrigin
@RestController
public class AdjustmentMedicineController {

    @Autowired
    AdjustmentMedicineMapper basicmessageapper;



       @GetMapping("/AdjustmentmedicineBysmid")
    public ResponseResult medicine(Integer pageIndex, Integer pageSize,Integer smid){
        List<AdjustmentMedicine> basicmessages = basicmessageapper.selectAll(pageIndex,pageSize,smid);
        System.out.println("pageIndex,"+pageIndex);
        PageBean<AdjustmentMedicine> pageBean=new PageBean<>();
        pageBean.setPageBeanList(basicmessages);
        pageBean.setPageIndex(pageIndex);
        pageBean.setPageSize(pageSize);
        pageBean.setTotalRecord(basicmessageapper.selectcount(smid));
        return new ResponseResult<PageBean<AdjustmentMedicine>>(pageBean,200,"OK");
    }


//通过id查
@GetMapping("/AdjustmentmedicineBysmids")
public List<AdjustmentMedicine> selectbuid(Integer smid){
    System.out.println("Id是"+smid);
    List<AdjustmentMedicine> basicmessageappers = basicmessageapper.SelectNumberBysmid(smid);

    return basicmessageappers;
}
//    //通过id修改
//    @GetMapping("/updates")
//    public void updatebuid( Integer smid){
//        System.out.println("需要修改状态的ID是"+smid);
//        basicmessageapper.update(smid);
//
//
//    }
//    //调价
//    @GetMapping("/updateDiarys")
//    public void updateDiarys( Integer smid,Double retail,Integer count,Double fretail){
//        System.out.println("需要调价的ID是"+smid);
//      Integer counts=basicmessageapper.selectDiarys(smid)+count;
//        System.out.println("counts,"+counts);
//        System.out.println("没改之前的retial是："+fretail);
//        basicmessageapper.updateDiarys(smid,retail,counts);
//
//
//    }

    //查询信息通过编号
//    @GetMapping("/Bynicknamaess")
//    public ResponseResult selectbuid( String name,Integer pageIndex,Integer pageSize ){
//
//        System.out.println("名字是"+name);
//        if(name.equals("") || name==null){
//            List<AdjustmentMedicine> basicmessages = basicmessageapper.selectAll(pageIndex,pageSize);
//            PageBean<AdjustmentMedicine> pageBean=new PageBean<>();
//            pageBean.setPageBeanList(basicmessages);
//            pageBean.setPageIndex(pageIndex);
//            pageBean.setPageSize(pageSize);
//            pageBean.setTotalRecord(basicmessageapper.selectcount());
//            return new ResponseResult<PageBean<AdjustmentMedicine>>(pageBean,200,"OK");
//        }else {
//            List<AdjustmentMedicine> basicmessages =basicmessageapper.SelctNumber(name);
//
//            PageBean<AdjustmentMedicine> pageBean=new PageBean<>();
//            pageBean.setPageBeanList(basicmessages);
//            pageBean.setPageIndex(pageIndex);
//            pageBean.setPageSize(pageSize);
//            pageBean.setTotalRecord(basicmessageapper.selectcount());
//            return new ResponseResult<PageBean<AdjustmentMedicine>>(pageBean,200,"OK");
//        }
//
//
//    }


}
